public class Test2 {
     static int tmp;
     int sum;
     public void fun3(){
         Thread thread=new Thread(){
             @Override
             public void run() {
                 sum++;
             }
         };
     }
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 50; i++) {
                    synchronized (Thread.class){
                        tmp++;
                    }
                }
            }
        };

        Thread thread1=new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 50; i++) {
                    synchronized (Thread.class){
                        tmp++;
                    }
                }
            }
        };
        thread.start();
        thread1.start();
        thread.join();
        thread1.join();
        System.out.println(tmp);

    }
}
